package cc.bukkitPlugin.banitem.check.nbtvalue;

public abstract class ANBTValue{

    protected final String mValue;

    public ANBTValue(String pValue){
        if(pValue==null)
            throw new IllegalArgumentException("NBT值不能为null");
        this.mValue=pValue;
    }

    public abstract boolean isInRange(String pStrValue);

    public String getRawValue(){
        return this.mValue;
    }

    public static ANBTValue createNBTValue(String pValue){
        if(pValue==null)
            pValue="";
        if(pValue.equals("*"))
            return new AllNBTValue();
        else if(pValue.contains("%value%"))
            return new ExpressNBTValue(pValue);
        else return new SimpleNBTValue(pValue);
    }

    @Override
    public boolean equals(Object pObject){
        if(pObject==null||pObject.getClass()!=this.getClass())
            return false;
        return this.hashCode()==pObject.hashCode();
    }

    @Override
    public int hashCode(){
        return this.mValue.hashCode();
    }

}
